package com.lang.count;

import com.lang.beans.Parcel;

/**
 * 计算运费
 * 
 * @author hao
 * 
 */
public class CountFare {
	public double count(Parcel p) {
		double price = 0;
		Float weight = p.getWeight();
		switch (p.getSize()) {
		case 0:
			price += 20;
			break;
		case 1:
			price += 15;
			break;
		case 2:
			price += 10;
			break;
		case 3:
			price += 6;
			break;
		case 4:
			price += 5;
			break;
		}
		if (weight > 5) {
			price += (3 + (weight - 5) * 2 * 8);
		}
		if (weight > 1 && weight <= 5) {
			price += (3 + (weight - 1) * 2 * 4);
		} else {
			price += weight * 2 * 3;
		}
		return price;
	}

}
